package com.xoms.pad.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xoms.pad.aspect.datasource.DataSourceSwitcher;
import com.xoms.pad.controller.res.bean.RRoomBean;
import com.xoms.pad.model.RoomBean;
import com.xoms.pad.persist.impl.RoomImpl;
import com.xoms.pad.service.RoomService;

@Service
public class RoomServiceImpl implements RoomService {

	
	@Autowired
	RoomImpl roomImpl;
	

	@Override
	public List<RRoomBean> getRoom(String rid,String name,List<String> lists) {
		
				//获取数据源
				DataSourceSwitcher.setDataSourceType(DataSourceSwitcher.DATA_SOURCE_XOMS);
				//通过rid去查影厅
				List<RoomBean> rooms = new  ArrayList<>();
				rooms = roomImpl.selectRoom(rid,name,lists);
				if (rooms == null || rooms.size()<=0) {
					return null;
				}
				List<RRoomBean> rRoomList = new ArrayList<>();
				for(RoomBean roomBean: rooms){
					RRoomBean rRoomBean = new RRoomBean();
					rRoomBean.setAccountId(roomBean.getAccountId());
					rRoomBean.setCreateTime(roomBean.getCreateTime());
					rRoomBean.setEndTime(roomBean.getEndTime());
					rRoomBean.setImgUrl(roomBean.getImgUrl());
					rRoomBean.setName(roomBean.getName());
					rRoomBean.setRid(roomBean.getRid());
					rRoomBean.setMaxCapacity(roomBean.getMaxCapacity());
					rRoomBean.setNumber(roomBean.getNumber());
					rRoomBean.setStatus(roomBean.getStatus());
					rRoomBean.setTheatreId(roomBean.getTheatreId());
					rRoomBean.setTypeId(roomBean.getTypeId());
					rRoomList.add(rRoomBean);
				}
				return rRoomList;
	}





	


}
